create function dbo.MakeDate(
						@iYear int,
						@iMonth int,
						@iDay int,
						@iHour int=0,
						@iMinute int=0,
						@iSecond int=0) 
returns
    smalldatetime
as
begin
	declare @NewDateTime smalldatetime

	set @NewDateTime=
	    convert(
		    smalldatetime,
		    convert(varchar(25),@iYear)
			+ '.' + convert(varchar(25),@iMonth)
			+ '.' + convert(varchar(25),@iDay))

	set @NewDateTime=dateadd(hour,@iHour,@NewDateTime)
	set @NewDateTime=dateadd(minute,@iMinute,@NewDateTime)
	set @NewDateTime=dateadd(second,@iSecond,@NewDateTime)

	return @NewDateTime
end